package com.sky.controller.user;

import com.sky.entity.Category;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户的分类相关接口
 */
@RestController("userCategoryController")
@RequestMapping("/user/category")
@Api(tags = "用户的分类相关接口")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    /**
     * 用户根据菜品分类的类型获取分类
     */
    @GetMapping("/list")
    @ApiOperation(value = "用户根据菜品分类的类型获取分类")
    public Result list(Integer type) {
        List<Category> categories = categoryService.userGetCategoriesByType(type);
        return Result.success(categories);
    }
}